Full source code website bán hàng thương mại điện tử gần giống shopee
468.933 lượt xem;
1 <table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Danh thư viện : <b> <a href="./?act=edoc_category_m"><font color="#FFFFFF">Nhập
5 Mới</font></a><font color="#FFFFFF"> </font></b></td>
6 </tr>
7 </table>
8 <?
9 switch ($_GET['action'])
10 {
11 case 'del' :
12 $id = $_GET['id'];
13 $result = mysql_query("select doc_images_categoriesid from doc_images where doc_images_categoriesid='".$id."'",$con);
14 if (mysql_num_rows($result)<=0) {
15 $sql = "delete from doc_categories where doc_categories_id='".$id."'";
16 @$result = mysql_query($sql,$con);
17 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
18 else echo "<p align=center class='err'>Không thể xóa dữ liệu</font></p>";
19 } else {
20 echo "<p align=center class='err'>Đang có sản phẩm sử dụng. nên bạn không thể xóa</p>";
21 }
22
23 break;
24 }
25 ?>
26
27 <?
28 if (isset($_POST['ButDel'])) {
29 $cnt=0;
30 foreach ($_POST['chk'] as $id)
31 {
32 @$result = mysql_query("delete from doc_categories where doc_categories_id='".$id."'",$con);
33 if ($result) $cnt++;
34 }
35 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
36 }
37 ?>
38 <?
39 $page = $_GET["page"];
40 $MAXPAGE=10;
41 $p=0;
42 if ($page!='') $p=$page;
43 $where="1=1";
44 if ($_REQUEST['cat']!='') $where="doc_categories_parentid=".$_REQUEST['cat'];
45
46 ?>
47 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
48 <input type="hidden" name="act" value="edoc_category">
49 <input type=hidden name="page" value="<? echo $page; ?>">
50 <?
51 function taotrang($sql,$link,$nitem,$itemcurrent)
52 { global $con;
53 $ret="";
54 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
55 $value = mysql_fetch_array($result);
56 $plus = (($value['cnt'] % $nitem)>0);
57 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
58 {
59 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
60 else $ret .= ($i+1)." ";
61 }
62 return $ret;
63 }
64 $pageindex=taotrang("select count(*) from doc_categories where $where and doc_categories_parentid>0","./?act=edoc_category"."&page=",$MAXPAGE,$page);
65 ?>
66
67 <? if ($_REQUEST['code']==1) echo "<p align=center class='err'>Đã cập nhật thành công</p>"; ?>
68
69 <table cellspacing="0" cellpadding="0" width="100%">
70 <tr>
71 <td class="smallfont" >Trang : <? echo $pageindex; ?></td>
72 <td height="30" align="right" class="smallfont">
73 <select size="1" name="ddCat" class="smallfont">
74 <?
75 $ms=GetListDoc(1);
76 echo '<option value="">[Tất cả]</option>';
77 foreach ($ms as $m)
78 if ($m[0]!=$_REQUEST['cat'])
79 echo '<option value="'.$m[0].'">'.$m[1].'</option>';
80 else
81 echo '<option selected value="'.$m[0].'">'.$m[1].'</option>';
82 ?>
83 </select>
84 <input type="button" value="Chuyển" class="button" onclick="window.location='./?act=edoc_category&cat='+ddCat.value">
85 </td>
86 </tr>
87
88 </table>
89
90 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
91 <tr>
92 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
93 <td nowrap class="title"> </td>
94 <td nowrap class="title"> </td>
95 <td align="center" nowrap class="title"><b>Mã</b></td>
96 <td align="center" nowrap class="title"><b>Tên</b></td>
97 <td align="center" nowrap class="title"><b>Thuộc danh mục</b></td>
98 <td align="center" nowrap class="title"><b>Không hiển thị</b></td>
99 <td align="center" nowrap class="title"><b>Ngày</b></td>
100 </tr>
101
102 <?
103 $sql="select *,DATE_FORMAT(date_added,'%d/%m/%Y %h:%m') as dateformat from doc_categories where $where and doc_categories_parentid>0 order by doc_categories_id limit ".($p*$MAXPAGE).",".$MAXPAGE;
104 $result=mysql_query($sql,$con);
105 $i=0;
106 while(($row=mysql_fetch_array($result)))
107 {
108 $i++;
109 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
110 $parentname="";
111 if ($row['doc_categories_parentid']>1)
112 {
113 $sqlcat="select * from doc_categories where doc_categories_id='".$row['doc_categories_parentid']."' limit 1";
114 $rowsub=mysql_fetch_array(mysql_query($sql,$con));
115 $parentname=$rowsub['doc_categories_name'];
116 }
117 else
118 $parentname="Thư mục gốc";
119 ?>
120
121 <tr>
122 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
123 <input type="checkbox" name="chk[]" value="<? echo $row['doc_categories_id']; ?>"></td>
124 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
125 <a href="./?act=edoc_category_m&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['doc_categories_id']; ?>">Sửa</a></td>
126 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
127 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=edoc_category&page=<? echo $_REQUEST['page']; ?>&action=del&id=<? echo $row['doc_categories_id']; ?>">Xoá</a></td>
128 <td width="20" bgcolor="<? echo $color; ?>" align="left" width="55" align="left" class="smallfont"><? echo $row['doc_categories_id']; ?> </td>
129 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['doc_categories_name']; ?> </td>
130 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $parentname; ?> </td>
131 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['doc_categories_status']; ?> </td>
132 <td width="100" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['dateformat']; ?> </td>
133 </tr>
134 <?
135 }
136 ?>
137 </table>
138 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
139 </form>
140 <script language="JavaScript">
141 function chkallClick(o) {
142 var form = document.frmList;
143 for (var i = 0; i < form.elements.length; i++) {
144 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
145 form.elements[i].checked = document.frmList.chkall.checked;
146 }
147 }
148 }
149 </script>
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Danh thư viện : <b> <a href="./?act=edoc_category_m"><font color="#FFFFFF">Nhập
5 Mới</font></a><font color="#FFFFFF"> </font></b></td>
6 </tr>
7 </table>
8 <?
9 switch ($_GET['action'])
10 {
11 case 'del' :
12 $id = $_GET['id'];
13 $result = mysql_query("select doc_images_categoriesid from doc_images where doc_images_categoriesid='".$id."'",$con);
14 if (mysql_num_rows($result)<=0) {
15 $sql = "delete from doc_categories where doc_categories_id='".$id."'";
16 @$result = mysql_query($sql,$con);
17 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
18 else echo "<p align=center class='err'>Không thể xóa dữ liệu</font></p>";
19 } else {
20 echo "<p align=center class='err'>Đang có sản phẩm sử dụng. nên bạn không thể xóa</p>";
21 }
22
23 break;
24 }
25 ?>
26
27 <?
28 if (isset($_POST['ButDel'])) {
29 $cnt=0;
30 foreach ($_POST['chk'] as $id)
31 {
32 @$result = mysql_query("delete from doc_categories where doc_categories_id='".$id."'",$con);
33 if ($result) $cnt++;
34 }
35 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
36 }
37 ?>
38 <?
39 $page = $_GET["page"];
40 $MAXPAGE=10;
41 $p=0;
42 if ($page!='') $p=$page;
43 $where="1=1";
44 if ($_REQUEST['cat']!='') $where="doc_categories_parentid=".$_REQUEST['cat'];
45
46 ?>
47 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
48 <input type="hidden" name="act" value="edoc_category">
49 <input type=hidden name="page" value="<? echo $page; ?>">
50 <?
51 function taotrang($sql,$link,$nitem,$itemcurrent)
52 { global $con;
53 $ret="";
54 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
55 $value = mysql_fetch_array($result);
56 $plus = (($value['cnt'] % $nitem)>0);
57 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
58 {
59 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
60 else $ret .= ($i+1)." ";
61 }
62 return $ret;
63 }
64 $pageindex=taotrang("select count(*) from doc_categories where $where and doc_categories_parentid>0","./?act=edoc_category"."&page=",$MAXPAGE,$page);
65 ?>
66
67 <? if ($_REQUEST['code']==1) echo "<p align=center class='err'>Đã cập nhật thành công</p>"; ?>
68
69 <table cellspacing="0" cellpadding="0" width="100%">
70 <tr>
71 <td class="smallfont" >Trang : <? echo $pageindex; ?></td>
72 <td height="30" align="right" class="smallfont">
73 <select size="1" name="ddCat" class="smallfont">
74 <?
75 $ms=GetListDoc(1);
76 echo '<option value="">[Tất cả]</option>';
77 foreach ($ms as $m)
78 if ($m[0]!=$_REQUEST['cat'])
79 echo '<option value="'.$m[0].'">'.$m[1].'</option>';
80 else
81 echo '<option selected value="'.$m[0].'">'.$m[1].'</option>';
82 ?>
83 </select>
84 <input type="button" value="Chuyển" class="button" onclick="window.location='./?act=edoc_category&cat='+ddCat.value">
85 </td>
86 </tr>
87
88 </table>
89
90 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
91 <tr>
92 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
93 <td nowrap class="title"> </td>
94 <td nowrap class="title"> </td>
95 <td align="center" nowrap class="title"><b>Mã</b></td>
96 <td align="center" nowrap class="title"><b>Tên</b></td>
97 <td align="center" nowrap class="title"><b>Thuộc danh mục</b></td>
98 <td align="center" nowrap class="title"><b>Không hiển thị</b></td>
99 <td align="center" nowrap class="title"><b>Ngày</b></td>
100 </tr>
101
102 <?
103 $sql="select *,DATE_FORMAT(date_added,'%d/%m/%Y %h:%m') as dateformat from doc_categories where $where and doc_categories_parentid>0 order by doc_categories_id limit ".($p*$MAXPAGE).",".$MAXPAGE;
104 $result=mysql_query($sql,$con);
105 $i=0;
106 while(($row=mysql_fetch_array($result)))
107 {
108 $i++;
109 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
110 $parentname="";
111 if ($row['doc_categories_parentid']>1)
112 {
113 $sqlcat="select * from doc_categories where doc_categories_id='".$row['doc_categories_parentid']."' limit 1";
114 $rowsub=mysql_fetch_array(mysql_query($sql,$con));
115 $parentname=$rowsub['doc_categories_name'];
116 }
117 else
118 $parentname="Thư mục gốc";
119 ?>
120
121 <tr>
122 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
123 <input type="checkbox" name="chk[]" value="<? echo $row['doc_categories_id']; ?>"></td>
124 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
125 <a href="./?act=edoc_category_m&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['doc_categories_id']; ?>">Sửa</a></td>
126 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
127 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=edoc_category&page=<? echo $_REQUEST['page']; ?>&action=del&id=<? echo $row['doc_categories_id']; ?>">Xoá</a></td>
128 <td width="20" bgcolor="<? echo $color; ?>" align="left" width="55" align="left" class="smallfont"><? echo $row['doc_categories_id']; ?> </td>
129 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['doc_categories_name']; ?> </td>
130 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $parentname; ?> </td>
131 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['doc_categories_status']; ?> </td>
132 <td width="100" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['dateformat']; ?> </td>
133 </tr>
134 <?
135 }
136 ?>
137 </table>
138 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
139 </form>
140 <script language="JavaScript">
141 function chkallClick(o) {
142 var form = document.frmList;
143 for (var i = 0; i < form.elements.length; i++) {
144 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
145 form.elements[i].checked = document.frmList.chkall.checked;
146 }
147 }
148 }
149 </script>